/**
 * @author Owen
 */
 function switchSearch(div){
				wipeDiv(div);
			
				if(dojo.byId("advancedSearchLink").className == "active"){
					dojo.byId("advancedSearchLink").className = "";
				}else{
					dojo.byId("advancedSearchLink").className = "active";
				}
			}
 
function wipeDiv(div){
	var wipeOut = dojo.fx.wipeOut({node: div,duration: 500});
	var wipeIn = dojo.fx.wipeIn({node: div,duration: 500});
	
	if(dojo.byId(div).style.display == "none"){
		wipeIn.play();
	}else{
		wipeOut.play();
	}
}

function chgText(div,string1,string2){
	var element = dojo.byId(div);
	if(element.innerHTML == string1){
		element.innerHTML = string2;
	}else{
		element.innerHTML = string1;
	}
}

function chgOtherText(div,str1,str2){
	chgText(div,str1,str2);
}

function chgImg(div,img1,img2){
	var element = dojo.byId(div);
	if(element.src.indexOf(img1) > 0){
		element.src = "./ui/v8/script/" + img2;
	}else{
		element.src = "./ui/v8/script/" + img1;
	}
}

function chgOtherImg(div,img1,img2){
	chgImg(div,img1,img2);
}

function showSubMenu(id){
	document.getElementById(id).style.display = 'block';
}
		
function hideSubMenu(id){
	dojo.byId(id).style.display = 'none';
}

function hideSubMenus(){
	hideSubMenu('sub1');
}

function ajaxRequest (href, callback, errorCallback) {
	var req;
	
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (!req) {
        // Unable to initiate the request
        errorCallback();
        return;
    } 
	if(req) {
		req.open("POST",href,true);
		req.onreadystatechange = function() { ajaxStateChange(req, callback, errorCallback)};
		req.send(null);
	}
	
}

function ajaxStateChange (ajax_request, callback, errorCallback) {
    if (ajax_request.readyState == 4) {
        if (ajax_request.status == 200) {

            if (callback) { 
                callback(ajax_request);
            } 
        } else {
            if (errorCallback) {
                errorCallback;  
            } 
        }
    }
}
